package com.oa.framework.acc.account.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.oa.common.exception.CreateObjectException;
import com.oa.common.exception.UpdateObjectException;
import com.oa.framework.acc.account.domain.AccountPrincipal;
import com.oa.framework.acc.account.domain.UserAccount;
import com.oa.framework.acc.account.domain.UserSecurityInfo;
import org.springframework.security.core.userdetails.UserDetailsService;

/**
 * @author cuichao
 * 用户账号Service
 */
public interface UserAccountService  {

    /**
     * 分页搜索用户(携带主要信息)
     * @param page
     * @return
     */
    IPage<UserAccount> searchAccountIncludePriorityPrincipal(IPage<UserAccount> page);

    /**
     * 创建用户账号
     * @param account
     * @return
     * @throws CreateObjectException
     */
    boolean createUserAccount(UserAccount account) throws CreateObjectException;
    /**
     * 修改用户账号信息
     * @param account
     * @return
     * @throws UpdateObjectException
     */
    boolean updateUserAccount(UserAccount account) throws UpdateObjectException;

    /**
     * 为用户添加身份
     * @param accountId
     * @param principal
     * @return
     */
    AccountPrincipal addUserAccountPrincipal(Long accountId, AccountPrincipal principal) throws CreateObjectException;
    /**
     * 更新用户身份
     * @param accountId
     * @param principal
     * @return
     */
    boolean updateUserAccountPrincipal(Long accountId, AccountPrincipal principal);
    /**
     * 移除身份
     * @param principalId
     * @return
     */
    boolean removeAccountPrincipal(Long accountId, Long principalId);

    /**
     * 获得用户信息(用户多身份)
     * @param accountId
     * @return
     */
    UserAccount getUserAccountIncludePrincipalsByAccountId(Long accountId);

    /**
     * 加载用户安全信息
     * @param username
     * @return
     */
    UserSecurityInfo loadUserAccountSecurityInfo(String username);


}
